package com.example.Laboratory.Mapper;

import com.example.Laboratory.Entity.News;
import org.apache.ibatis.annotations.*;

import java.util.List;


@Mapper
public interface NewsMapper {

    //增加新闻
    @Insert("Insert into news(news_title,news_publisher,news_time,news_text,news_address1,news_address2)Values(#{news_title},#{news_publisher},#{news_time},#{news_text},#{news_address1},#{news_address2})")
    int addNews(News t);

    //根据id删除新闻
    @Delete("DELETE FROM news WHERE news_id=#{news_id}")
    int deleteNews(int news_id);
    //

    //用全部信息更新(新闻)
    @Update("UPDATE news SET news_name=#{news_title=#{news_title},news_publisher=#{news_publisher},news_time=#{news_time},news_text=#{news_text},news_address=#{news_address} where news_id=#{news_id}")
    int reviseNews(News t);

    //单条查找全表信息(新闻)
    @Select("SELECT * FROM news WHERE news_id=#{news_id}")
    List<News> researchNews1(int news_id);

    //多条查找返回标题(新闻)
    @Select("SELECT news_title,news_time FROM news")
    List<News> researchNews2();

    //查找图片1的地址
    @Select("SELECT news_address1 FROM news WHERE news_id=#{news_id}")
    String researchaddress1(int news_id);

    //查找图片2的地址
    @Select("SELECT news_address2 FROM news WHERE news_id=#{news_id}")
    String researchaddress2(int news_id);


}
